<?php 
/*****************
* 任务管理队列
*创建日期:2012-8-27
*作者：tjx
******************/

define('IN_WONDERSHARE', true);
header("Content-type:text/html;charset=utf-8");
ob_start("ob_gzhandler");

require('../includes/init.php');
require('./configs/site_config.php');
			
class TaskQueue {
	
	private  $db;
	private  $table;
	/**
	* @ 构造函数
	* @ __construct
	*/
	
	public function __construct() {
		$this->db = $GLOBALS['db'];
		$this->table = 'task_queue';
	}


	/**
	* 查看队列
	* @param   string      		 $q_user_name      用户名称
	* @return  array
	*/
	public function index() {
		
		$queue_rows = queueSelect();
		
		$GLOBALS['smarty']->assign('queue_rows', $queue_rows);
		$GLOBALS['smarty']->assign('total', count($queue_rows));
		$GLOBALS['smarty']->display('task_queue_list.htm');  

		
	}
	
	/**
	* 删除队列记录
	* @param   int      		$qid       队列主键
	* @param   int        	 	 $id       编辑ID
	* @return  array
	*/
	public function delete() {
		
		if ($_GET['type'] == 'delAll') {
			
			queueDelete('', 0, $_GET['type']);
			echo  '清除我的队列成功';
			exit;

		} elseif ( !empty($_GET['str_qid']) ) {
			echo  queueDelete($_GET['str_qid']);
			
		} else if(!empty($_GET['id']) && !empty($_GET['url'])){
		    echo  queueDelete('',$_GET['id'],'', $_GET['url']);
		    
		} else if (!empty($_GET['d_id']) && !empty($_GET['t_id'])){
			echo  queueDelete('','','','' ,$_GET['t_id'] , $_GET['d_id'] );
		}
		
	}

}

$action    = $_REQUEST['action']; 
$task_queue   = new TaskQueue;
if ( method_exists($task_queue, $action) )  {
	$task_queue->$action();
} else {
	$task_queue->index();
}

?>
